﻿using WeatherSpider.Spider;

var provincesInfo = await CmaWeatherSpider.GetCityInfo();

Console.Clear();

for(; ; )
{
    Console.Write("输入城市名称(按Ctrl+C退出): ");
    var cityName = Console.ReadLine();

    var city = (from province in provincesInfo
                where province.Cities.Any(c => c.Name == cityName)
                select province.Cities.First(c => c.Name == cityName)).FirstOrDefault();

    if (city is null)
    {
        Console.WriteLine("未找到指定城市.");
        continue;
    }

    var weather = await CmaWeatherSpider.GetWeekWeather(city);

    Console.WriteLine($"-----------------------{city.Name}七日天气--------------------------");

    foreach (var weatherItem in weather)
    {
        Console.WriteLine(weatherItem);
    }
}
